***********************************************************************************************************
******** Replication Code for Online Appendix *************************************************************
*** Bøttkjær & Justesen "Why do voters support corrupt politicians?Experimental evidence from South Africa"
*** Please run the do-file "Do_run_me_first_JOP" before running the replication code for the appendix
*** Before running, install 'outreg2' command: ssc install outreg2 
***********************************************************************************************************


**************************************************************
*************** Appendix A ***********************************
******** See pdf-file Online Appendix ************************
**************************************************************


******************************************
*************** Appendix B ***************
* Figure B: Distribution of outcome
sum outcome43
mean outcome43

hist outcome43, percent graphregion(fcolor(white)) plotregion(fcolor(white)) bcolor(gs12) bin(5)/*
*/ title(Figure B. Support for political candidates) subtitle(Distribution of outcome variable) xtitle(Likelihood of voting for candidate) /*
*/ note("mean=1.50; sd=1.46; n=1452")


*************** Appendix C ***************
*** Summary statistics 

sum outcome43
sum QR43
sum anc_partisan
sum da_partisan
sum female
sum Age
sum edu
sum unemp
sum LSM14_0
sum poverty100
sum race_black
sum race_coloured
sum race_white
sum urban
sum easterncape
sum freestate
sum gauteng
sum kwazulunatal
sum limpopo
sum mpumalanga
sum northerncape
sum northwest
sum westerncape
sum ANCvote2016 
sum DAvote2016 
sum votemargin

**************************************************************
************** Appendix D ************************************
******** See pdf-file Online Appendix ************************ 
**************************************************************


******************************************
*************** Appendix E ***************
***** Power tests

*** a priori analysis.
* suppose we expect the difference-in-means between two groups to be 0.5 with a standard deviation of 1.5. 
power twomeans 1.5 1.0, sd(1.5)

*** post hoc analysis. 
**summary statistics to use in the post hoc power analysis.
bysort QR43: sum outcome

**calculating statistical power.
*Control (Non-corruption) vs. Treatment1 (Corruption).
power twomeans 1.205479 2.534247, sd1(1.376872) sd2(1.441479) n1(292) n2(292)

*Control (Non-corruption) vs. Treatment2 (ANC partisanship).
power twomeans  1.171233 2.534247, sd1(1.330889) sd2(1.441479) n1(292) n2(292)

*Control (Non-corruption) vs. Treatment3 (DA partisanship).
power twomeans  1.117647 2.534247, sd1(1.244432) sd2(1.441479) n1(289) n2(292)

*Control (Non-corruption) vs. Treatment5 (Patronage).
power twomeans  1.473868 2.534247, sd1(1.4186) sd2(1.441479) n1(287) n2(292)

*Treatment1 (Corruption) vs. Treatment2 (ANC partisanship).
power twomeans  1.171233 1.205479, sd1(1.330889) sd2(1.376872) n1(292) n2(292)

*Treatment1 (Corruption) vs. Treatment3 (DA partisanship).
power twomeans  1.117647 1.205479, sd1(1.244432) sd2(1.376872) n1(289) n2(292)

*Treatment1 (Corruption) vs. Treatment5 (Patronage).
power twomeans  1.473868 1.205479, sd1(1.4186) sd2(1.376872) n1(287) n2(292)

**calculating sample size to obtain statistical power of 0.8.
*Treatment1 (Corruption) vs. Treatment2 (ANC partisanship).
power twomeans  1.171233 1.205479, sd1(1.330889) sd2(1.376872)

*Treatment1 (Corruption) vs. Treatment3 (DA partisanship).
power twomeans  1.117647 1.205479, sd1(1.244432) sd2(1.376872)


**************************************************************
************** Appendix F ************************************
******** See pdf-file Online Appendix ************************ 
**************************************************************


*************** Appendix G ***************
*** Survey experiment and party dominance 

* Baseline results
reg outcome43 i.QR43, r cluster(EA_Numbe)
outreg2 using appendixG.doc, word bdec(2) tstat tdec(2) replace

* Interaction with ANC vote share - proxy for ANC dominance
reg outcome43 i.QR43##c.ANCvote2016, r cluster(EA_Numbe)
outreg2 using appendixG.doc, word bdec(2) tstat tdec(2) append

* Interaction with DA vote share - proxy for DA challenge
reg outcome43 i.QR43##c.DAvote2016, r cluster(EA_Numbe)
outreg2 using appendixG.doc, word bdec(2) tstat tdec(2) append

* Interaction with vote margin - proxy for electoral contestation
reg outcome43 i.QR43##c.votemargin, r cluster(EA_Numbe)
outreg2 using appendixG.doc, word bdec(2) tstat tdec(2) append


******************************************
*************** Appendix H ***************
*** Missingness on outcome **********

sum outcome43
gen missing = 1 if outcome43 ==.
replace missing = 0 if outcome43!=.
tab missing

reg missing i.QR43
outreg2 using appendixH.doc, word bdec(2) tstat tdec(2) append

******************************************
*************** Appendix I ***************
*** Regression Tabel for Figure 1 **********

reg outcome43 i.QR43, r cluster(EA_Numbe)
outreg2 using appendixI.doc, word bdec(2) tstat tdec(2) replace

reg outcome43 ib5.QR43, r cluster(EA_Numbe)
outreg2 using appendixI.doc, word bdec(2) tstat tdec(2) append


*******************************************************************
*************** Appendix J ****************************************
*** Comparison of straight means of voter support (outcome variable by treatment groups)
graph bar (mean) outcome43, over(QR43) blabel(bar) graphregion(fcolor(white)) plotregion(fcolor(white))/*
*/ title("Figure J. Comparison of means") ytitle(Mean voter support)  /*
*/ note(Note. Y-axis is mean voter support for candidate)	


******************************************
*************** Appendix K ***************
*** Balance tests ************************

*Gender.
oneway female QR43, tab

*Age.
oneway Age QR43, tab

*Education.
oneway edu QR43, tab

*Unemployment
oneway unemp QR43, tab

*Living standard.
oneway LSM14_0 QR43, tab

*Race
oneway race_black QR43, tab
oneway race_white QR43, tab
oneway race_coloured QR43, tab

* Urban-rural 
oneway urban QR43, tab

*Province.
oneway easterncape QR43, tab
oneway freestate QR43, tab
oneway gauteng QR43, tab
oneway kwazulunatal QR43, tab
oneway limpopo QR43, tab
oneway mpumalanga QR43, tab
oneway northerncape QR43, tab
oneway northwest QR43, tab
oneway westerncape QR43, tab

*******************************************************************
*************** Appendix L ****************************************
*** Reproducing Figure 1 (regression table) with covariate controls 

*** Base model (Panel A): Outcome versus treatment group
reg outcome43 i.QR43  female Age i.racialgroup edu unemp LSM14_0 i.urban i.Province, r cluster(EA_Numbe)
outreg2 using appendixL.doc, word bdec(2) tstat tdec(2) replace

		* Reproduce Panel 1A: Coefficient plot 
		margins r.QR43, 
		marginsplot, horizontal unique xline(0) xscale(range(-2.0 0.1)) xlabel(-2(0.1)0.1, angle(45)) yscale(reverse) recast(scatter) ciopts(lpattern(dash)) /*
		*/ graphregion(fcolor(white)) plotregion(fcolor(white)) title("Figure L.1. Voting for corrupt candidates") subtitle("Effects of information, party identity, and patronage") /*
		*/ ytitle(Treatment groups (relative to control)) xtitle(Coefficient size: Marginal effect of treatments)


		* Reproduce Panel 1B: Comparing patronage treatment
		reg outcome43 ib5.QR43 , r cluster(EA_Numbe)
		margins rb5.QR43,  
		marginsplot, horizontal unique xline(0) yscale(reverse) recast(scatter) ciopts(lpattern(dash)) graphregion(fcolor(white)) plotregion(fcolor(white))/*
		*/ title("Figure L.2. Corruption and patronage") ytitle(Comparisons to patronage treatment) xtitle(Coefficient plot: Comparisons with patronage treatment)

		
******************************************
*************** Appendix M ***************
*** Full set of results for Figure 2 *****

* ANC partisans: 
reg outcome43 i.QR43##i.anc_partisan, r cluster(EA_Numbe)
outreg2 using appendixM.doc, word bdec(2) tstat tdec(2) replace

* DA partisans
reg outcome43 i.QR43##i.da_partisan, r cluster(EA_Numbe)
outreg2 using appendixM.doc, word bdec(2) tstat tdec(2) append


*********************************************************
*************** Appendix N ******************************
*** Full set of results for interaction model in Figure 3 

reg outcome43 i.QR43##c.LSM14_0, r cluster(EA_Numbe)
outreg2 using appendixN.doc, word bdec(2) tstat tdec(2) replace

reg outcome43 i.QR43##c.poverty100, r cluster(EA_Numbe)
outreg2 using appendixN.doc, word bdec(2) tstat tdec(2) append

reg outcome43 i.QR43##c.edu, r cluster(EA_Numbe)
outreg2 using appendixN.doc, word bdec(2) tstat tdec(2) append

reg outcome43 i.QR43##c.unemp, r cluster(EA_Numbe)
outreg2 using appendixN.doc, word bdec(2) tstat tdec(2) append


******************************************
*************** Appendix O ***************
* Full set of results for interaction model in Figure 3, including controls

reg outcome43 i.QR43##c.LSM14_0 female Age i.racialgroup edu unemp LSM14_0 i.urban i.Province, r cluster(EA_Numbe)
outreg2 using appendixO.doc, word bdec(2) tstat tdec(2) replace

reg outcome43 i.QR43##c.poverty100 female Age i.racialgroup edu unemp LSM14_0 i.urban i.Province, r cluster(EA_Numbe)
outreg2 using appendixO.doc, word bdec(2) tstat tdec(2) append

reg outcome43 i.QR43##c.edu female Age i.racialgroup edu unemp LSM14_0 i.urban i.Province, r cluster(EA_Numbe)
outreg2 using appendixO.doc, word bdec(2) tstat tdec(2) append

reg outcome43 i.QR43##c.unemp female Age i.racialgroup edu unemp LSM14_0 i.urban i.Province, r cluster(EA_Numbe)
outreg2 using appendixO.doc, word bdec(2) tstat tdec(2) append

***** End **** 
